#ifndef WEBSOCKETDATA_H
#define WEBSOCKETDATA_H
#include "Buffer.hpp"

class Buffer;
class WebSocketData {
public:
    bool peekBuffer(Buffer* buffer);

    void readFromBuffer(Buffer* buffer);
    void writeToBuffer(Buffer* buffer);

    void setPayLoad(const std::string& payload); // 默认fin都是true，默认optcode为1

    inline std::string getPayLoad(){
        return payload_;
    }
    inline int getOptcode() {
        return head_ & 0x0F;
    }
    
private:
    char head_;
    bool masked_;
    size_t len_=0;
    // uint16_t lenU16_=-1;
    // uint64_t lenU64_=-1;
    std::vector<char> maskingkey_;


    // std::vector<char> payload_;
    std::string payload_;

};





#endif